package en.edu.zucc.pb.loginapplication.dao;

//import android.arch.lifecycle.LiveData;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Transaction;
import androidx.room.Update;

import java.util.List;

import en.edu.zucc.pb.loginapplication.db.BaseDao;
import en.edu.zucc.pb.loginapplication.entity.User;

//import en.edu.zucc.pb.room.entity.User;
//import en.edu.zucc.pb.room.entity.BooksAndUser;

//room 代码生成
@Dao
public interface UserDao extends BaseDao<User> {
//    @Query("SELECT * FROM user")
//    List<User> getAll();

//    @Query("SELECT * FROM user"+User.TABLE_NAME+User.class)
    @Query("SELECT * FROM "+User.TABLE_NAME)
//    LiveData<List<User>> getAll();
    LiveData<List<User>> getAllLiveData();




    @Query("SELECT * FROM user where username=:username ")
    List<User> getByUsername(String username);

    @Query("SELECT * FROM user where username=:username ")
   LiveData< List<User>> getLvdaByUsername(String username);

//    @Transaction
//    @Query("SELECT * FROM User where id = :Userid")
//    public List<BooksAndUser> getUserWithBooks(long Userid);

//    @Query("SELECT * FROM user WHERE id IN (:ids)")
//    List<User> loadAllByIds(int[] ids);

//    @Query("SELECT * FROM User WHERE firstname LIKE :first AND " +
//            "lastname LIKE :last LIMIT 1")
//    User findByName(String first, String last);

//    @Insert
//    void insertAll(User... Users);
//
//    @Insert
//    long insert(User User);
//
//    @Update
//    void updateAll(User... Users);
//
//    @Delete
//    void delete(User User);
//
//    @Query("DELETE FROM User")
//    void clearAll();
}
